home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / BARNET / COMPILER / SATHER / !Sather / Library / Containrs / sa / arr < prev    next >
Text File  |  1996-07-16  |  2KB  |  59 lines

  1. ---------------------------> Sather 1.1 source file <--------------------------
  2. -- arr.sa: Simple algorithms for array structures
  3. -- Author: Benedict A. Gomes <gomes@tiramisu.ICSI.Berkeley.EDU>
  4. -- Copyright (C) 1995, International Computer Science Institute
  5. -- $Id: arr.sa,v 1.4 1996/07/16 04:38:11 holger Exp $
  6. --
  7. -- COPYRIGHT NOTICE: This code is provided WITHOUT ANY WARRANTY
  8. -- and is subject to the terms of the SATHER LIBRARY GENERAL PUBLIC
  9. -- LICENSE contained in the file: Sather/Doc/License of the
  10. -- Sather distribution. The license is also available from ICSI,
  11. -- 1947 Center St., Suite 600, Berkeley CA 94704, USA.
  12. -------------------------------------------------------------------
  13. -- $ARR{ETP}    : Array abstraction 
  14. -------------------------------------------------------------------
  15. abstract class $RO_ARR{ETP} < $CONTAINER{ETP} is
  16.    -- A read-only array which is the interface to other algorithm classes
  17.    
  18.    ind!: INT;
  19.    -- post 0<=result<size
  20.    -- Returns all the indices, which are the integers between 0 and size - 1 
  21.  
  22.    aget(i: INT): ETP;
  23.    -- pre has_ind(i)
  24.  
  25.    has_ind(i: INT): BOOL;
  26.    -- return 0<=i<size
  27.    -- This method could actually be implemented at this level
  28.  
  29. end;
  30. -------------------------------------------------------------------
  31. abstract class $ARR{ETP} < $RO_ARR{ETP} is
  32.    -- The indices are integers and lie in [0, size-1]
  33.    -- Similar to a MAP from ints to elements, but more restrictive conditions
  34.    -- The features are repeated here so as to restate the preconditions
  35.    -- Inherits: copy, size, capacity, elt! and has
  36.    -- size: INT;
  37.    -- elt!: ETP;
  38.    -- has(e: ETP): BOOL;
  39.    
  40.    ind!: INT;
  41.    -- post 0<=result<size
  42.    -- Returns all the indices, which are the integers between 0 and size - 1 
  43.  
  44.    aget(i: INT): ETP;
  45.    -- pre has_ind(i)
  46.    
  47.    aset(ind: INT,e: ETP);
  48.    -- pre has_ind(i)
  49.    
  50.     copy: SAME;
  51.     -- Redefined to narrow the return type
  52.    
  53.    has_ind(i: INT): BOOL;
  54.    -- return 0<=i<size
  55.    -- This method could actually be implemented at this level
  56.  
  57. end;
  58. -------------------------------------------------------------------   
  59.